var path = require('path');
var webpack = require('webpack');
var cleanWebpackPlugin = require('clean-webpack-plugin');
var copyWebpackPlugin = require('copy-webpack-plugin');
var sassLoader = 'style!css!sass?sourceMap=true&sourceMapContents=true';

module.exports = {
  devtool: 'cheap-module-eval-source-map',
  entry: [
    'webpack-hot-middleware/client',
    './src/app.js',
  ],
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'bundle.js',
    publicPath: '/static/',
  },
  module: {
    loaders: [{
      test: /\.jsx?$/,
      include: [
        path.resolve(__dirname, 'src'),
      ],
      loaders: ['react-hot', 'babel'],
    },
    {
      test: /\.scss$/,
      include: [
        path.resolve(__dirname, 'src'),
      ],
      loader: sassLoader
    },
    // {
    //   test: /\.less$/,
    //   include: [
    //     path.resolve(__dirname, 'src'),
    //   ],
    //   loader: 'less-loader'
    // },
    {
      test: /\.less$/,
      include: [
        path.resolve(__dirname, 'src'),
      ],
       loader: "style!css!less"
    },{
       test: /\.(eot|woff|woff2|svg)(\?*)?$/,
      include: [
        path.resolve(__dirname, 'src'),
      ],
       loader: "file"     
    }
    ],
  },
  resolve: {
    alias: {
      'react': path.join(__dirname, 'node_modules', 'react'),
    },
    extensions: ['', '.js', '.jsx', 'less','.scss', '.css'],
  },
  plugins: [
    new cleanWebpackPlugin(['build']),
    new copyWebpackPlugin([{
      from:path.resolve(__dirname, 'src'),
      to:'src'
    }]),
    new webpack.NoErrorsPlugin(),
    new webpack.HotModuleReplacementPlugin()
  ],
};
